const toast = ({title = '数据11加载中',icon = 'none',duration = 2000,mask = 'true'} = {}) => {
  wx.showToast({
    title,
    icon,
    duration,
    mask
  })
}
// 挂载到wx上全局可用
wx.toast = toast
//  toast() 调用函数, 传入对象 解构对象,并设置默认值,不传入对象{} 

const model = (Option = {}) => {
  return  new Promise((resolve)=>{  
    //默认值
    const defaultOpt={
      title:"提示",
      content:"确定执行该操作吗?",
      confirmColor:"#f3514f",
    }
    // 合并
    const opts=Object.assign({},defaultOpt,Option);

    wx.showModal({
      ...opts,
      complete: ({confirm,cancel}) => {
        confirm && resolve(true)
        cancel && resolve(false)
      }
    })
  })
}

wx.model=model

export {
  toast,
  model
}